﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Raven.Abstractions.Data;
using Raven.Client;
using Raven.Client.Document;
using Raven.Client.Indexes;

namespace PrairieAsunder.Data
{
    public class RavenStore
    {
        public IDocumentStore CreateDocumentStore()
        {
            var store = default(IDocumentStore);
            
#if DEBUG
            store = new Raven.Client.Embedded.EmbeddableDocumentStore
            {
                RunInMemory = false,
                DataDirectory = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Raven")
            };         
#else
            store = new Raven.Client.Embedded.EmbeddableDocumentStore
            {
                RunInMemory = false,
                DataDirectory = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Raven")
            };
#endif

            store.Initialize();
            IndexCreation.CreateIndexes(typeof(RavenStore).Assembly, store);
            return store;
        }
    }
}